<?php foreach($groups as $group): ?>
<div class="xzxxti">
    <div class="xzxxpto"><img src="<?php echo $group->getThumbCover('groupcover'); ?>" width="60" height="60" />  </div>
                <div class="xzxxc">
                    <div class="xzname"><a href="<?php echo url_for('theme/group?id='.$group->getId()); ?>"><?php echo $group->getName(); ?></a></div>
                    <div class="xzguanz"><span id='attention_people_num'><?php echo $group->getPeopleNum(); ?></span>个成员　
                        <a href="javascript:void(0);" class="attention" group_id="<?php echo $group->getId(); ?>" attenthon="0" >
                            +加入小组
                        </a>
                    </div>
                </div>
            </div>
<?php endforeach; ?>
<script type="text/javascript">

$(document).ready(function(){
    
    $(".attention").on('click',function(){
        var att_button = $(this);
        var w_id = $(this).attr('group_id');
        var is_attenthion = $(this).attr('attenthon');
        var url = '';
        var text = '',attenthon = 0;

        if(is_attenthion == 0){
            url = "<?php echo url_for('theme/attention'); ?>";
            text = '';
            attenthon = 1;
        }
        
        $.post(url,{"group_id":w_id},function(data){
            var msg = eval("("+data+")");
            
            if(msg.error == 0){
                att_button.text(text).attr('attenthon',attenthon);
                var num = msg.data.people_num;
                var people = msg.data.people;
                att_button.parents('DIV').find('#attention_people_num').text(num);
            }
            layer.msg(msg.msg);
        });
        
    });
    
});
</script>